<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->title}</title>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/admin.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--config[
th {text-align:right;}
td {text-align:left;}
-->
</style>
</head>
<body>
<div class="wrapper">
  <div class="title shadow titleBg">
    <table width="100%" border="0" cellspacing="1">
      <tr>
        <td><h1> {:$i->title} => {:if $i->p[0] eq "mod"}修改{:elseif $i->p[0] eq "add"}
      添加{:/if} <span>[<a href="{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/lists/0/{:$i->p[2]}">字段管理</a>]</h1></td>
      </tr>
    </table>
  </div>   
  <div class="content shadow">
    <form>
      <table width="100%" border="0" cellspacing="1">
       <tr>
          <th width="20%">排　　序：</th>
          <td width="80%"><input name="ordering" type="text" size="4" id="ordering" value="0" class="posted" /></td>
        </tr>
         <tr>
          <th width="20%">字段提示：</th>
          <td width="80%"><input name="name" type="text" size="20" id="name" value="" class="posted" /></td>
        </tr>
         <tr>
          <th width="20%">空值提示：</th>
          <td width="80%"><input name="emptyTip" type="text" size="40" id="emptyTip" value="" class="posted" /> (允许字段空值则留空)</td>
        </tr>
        <tr>
          <th width="20%">字段名称：</th>
          <td width="80%"><input name="field" type="text" size="20" id="field" value="" class="posted" /></td>
        </tr>
        <tr>
          <th>字段类型：</th>
          <td><select id="selectCode" >
              <option value=''>常用类型参考</option>
              <option value="text">单行文本</option>
              <option value="textarea">多行文本域</option>
              <option value="FCKeditor">编辑器文本域</option>
              <option value="checkbox">复选框</option>
              <option value="radio">单选按钮组</option>
              <option value="select">下拉列表</option>
              <option value="hidden">隐藏域</option>
           </select>
          <input name="type" type="text" id="type" value="" size="40" title="不能带有双引号,请根据需要适当修改参考代码" class="posted" />
           <select id="selectType" >
           	  <option value="">更多参考...</option>
              <option value="int(11) NOT NULL DEFAULT 0">int(11)</option>
              <option value="tinyint(1) NOT NULL DEFAULT 0">tinyint(1)</option>
              <option value="smallint(6) NOT NULL DEFAULT 0">smallint(6)</option>
              <option value="mediumint(8) NOT NULL DEFAULT 0">mediumint(8)</option>
              <option value="varchar(255) NOT NULL">varchar(255)</option>
              <option value="char(5) NOT NULL">char(5)</option>
              <option value="set('a','c','c')">set('a','c','c')</option>
              <option value="enum('a','c','c')">enum('a','c','c')</option>
              <option value="tinytext">tinytext</option>
              <option value="text">text</option>
              <option value="mediumtext">mediumtext</option>
              <option value="longtext">longtext</option>
            </select></td>
        </tr>
        <tr>
          <th>表单代码：</th>
          <td><textarea title="不能带有双引号,请根据需要适当修改参考代码" name="code" cols="60" rows="10" id="code" class="posted"></textarea></td>
        </tr>
        <tr>
          <th>&nbsp;</th>
          <td><input type="submit" value=" 提 交 " />
            &nbsp;
            <input type="reset" onclick="history.go(-1);" value=" 返 回 " /></td>
        </tr>
      </table>
    </form>
  </div>
</div>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/ui.all.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.core.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.draggable.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.dialog.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.post.js"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function(){
	$("form").post({
		sendUrl:'{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/{:if $i->p[0] eq "mod"}update/{:$i->p[1]}{:elseif $i->p[0] eq "add"}insert/0{:/if}/{:$i->p[2]}',
		goUrl:'{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/lists/-1/{:$i->p[2]}'
	});
});

$("#selectType").change( function() {
	$("#type").get(0).value = this.value;
});

$("#selectCode").change( function() {
	var code,field;
	field=$("#field").get(0).value;
	if(this.value=='text'){
		$("#type").get(0).value = "varchar(64) NOT NULL";
		code='<!--config{type=text}-->\n<input name="'+field+'" id="'+field+'" size="30" type="text" value="$value" />';
	}else if(this.value=='hidden'){
		$("#type").get(0).value = "varchar(64) NOT NULL";
		code='<!--config{type=hidden}-->\n<input name="'+field+'" id="'+field+'" type="hidden" value="$value" />';
	}else if(this.value=='textarea'){
		$("#type").get(0).value = "text";
		code='<!--config{type=textarea}-->\n<textarea name="'+field+'" id="'+field+'" cols="60" rows="8">$value</textarea>';
	}else if(this.value=='FCKeditor'){
		$("#type").get(0).value = "text";
		code='<!--config{type=FCKeditor}-->\nFCKeditor|Width=100%;Height=500';
	}else if(this.value=='checkbox'){
		$("#type").get(0).value = "varchar(24) NOT NULL";
		code='<!--config{type=checkbox}-->\n<input name="'+field+'" id="'+field+'" type="checkbox" value="1" />';
	}else if(this.value=='radio'){
		$("#type").get(0).value = "tinyint(1) NOT NULL DEFAULT 0";
		code='<!--config{type=radio}-->\n<label><input name="'+field+'" type="radio" value="1" checked="checked" />是</label> \n<label><input name="'+field+'" type="radio" value="0" />否</label>';
	}else if(this.value=='select'){
		$("#type").get(0).value = "varchar(32) NOT NULL";
		code='<!--config{type=select}-->\n<select name="'+field+'">\n    <option value="1" selected="selected">1</option>\n    <option value="2">2</option>\n</select>';
	}else{
		code=this.value;
	}
	$("#code").get(0).value = code;
});
</script>
</body>
</html>